<template>
  <div>
    <table
      border="1"
      width="700"
      style="border-collapse: collapse"
    >
      <caption>
        购物车
      </caption>
      <thead>
        <headbuy  :datah="goodList"/>
      </thead>
      <tbody>
        <king
        v-for="(item,index) in goodList"
        :key="index"
        :data="item"
        @onDel="onDel(index)"
        />
      </tbody>
      <tfoot>
        <tr>
          <td>合计:</td>
          <td colspan="5">
            <price-all :dataAll="goodList"/>
          </td>
        </tr>
      </tfoot>
    </table>
  </div>
</template>

<script>
import headbuy from './components/headbuy.vue'
import king from './components/king.vue'
import PriceAll from './components/priceAll.vue'
export default {
  components: { king, PriceAll, headbuy },
  data () {
    return {
      goodList: [
        {
          name: '诸葛亮',
          price: 1000,
          num: 1,
          checked: false
        },
        {
          name: '蔡文姬',
          price: 1500,
          num: 1,
          checked: false
        },
        {
          name: '妲己',
          price: 2000,
          num: 1,
          checked: false
        },
        {
          name: '鲁班',
          price: 2200,
          num: 1,
          checked: false
        }
      ]
    }
  },
  methods: {
    onDel (index) {
      this.goodList.splice(index, 1)
    }
  }

}
</script>

<style>
</style>
